import * as Blockly from 'blockly/core';

const SENSOR_HUE = 40;  //'#9e77c9'//40;


export const KEY_SELET = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown([
                ["A", "9"],
                ["B", "10"],
                ["C", "11"]
            ]), "KEY");
        this.setOutput(true);
        this.setTooltip();
    }
};

export const AS_KEY_SELET = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown([
                ["A", "10"],
                ["B", "11"]
            ]), "KEY");
        this.setOutput(true);
        this.setTooltip();
    }
};

export const sensor_button_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("初始化");
        this.appendValueInput('key')
            .appendField("按键");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:初始化按键");
    }
};


export const sensor_light_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("初始化");
        this.appendDummyInput()
            .appendField("光敏传感器");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:初始化光敏传感器");
    }
};

export const sensor_light_read = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("光敏采集");
        this.appendDummyInput()
            .appendField("值");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:光敏传感器值-2047~+2047");
    }
};

export const sensor_button_read = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('key')
            .appendField("按键");
        this.appendDummyInput()
            .appendField("被按下?")
        this.setInputsInline(true);
        this.setOutput(true, [Boolean, Number]);
        this.setTooltip("[Teaile]:获取按键值");
    }
};


export const sensor_adc_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("ADC 初始化");
        this.appendValueInput('key')
            .appendField("增益量程");
        this.appendValueInput('SUB')
            .setCheck("var")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("通信");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:传感器ADS1015,采集模拟输入值");
    }
};

export const sensor_adc_read = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("ADC 采集");
        this.appendValueInput('value')
            .appendField("通道")
            .setCheck(Number);
        this.appendDummyInput()
            .appendField("值");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:传感器ADS1015，采集0-3通道模拟输入值-2047~+2047");
    }
};

export const sensor_adc_Vread = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("ADC 采集");
        this.appendValueInput('value')
            .appendField("通道")
            .setCheck(Number);
        this.appendDummyInput()
            .appendField("电压(V)");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:传感器ADS1015，采集0-3通道模拟输入电压值(V)");
    }
};


export const sensor_mpu9250_get_acceleration = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("MPU9250")
            .setCheck("var");
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION)
            .appendField(new Blockly.FieldDropdown([
                ["x", "x"],
                ["y", "y"],
                ["z", "z"],
                ["(x,y,z)", "values"]
            ]), "key");
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION);
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
            var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
            var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION1;
            var TOOLTIPS = {
                'x': 'x',
                'y': 'y',
                'z': 'z',
                '(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
            };
            return mode0 + TOOLTIPS[mode] + mode1 + mode2;
        });
    }
};

//--开始--------------------------新增-20211227-------------------------------------------------
export const sensor_use_i2c_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('I2CSUB')
            .appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH + "I2C")
            .setCheck("var");
        this.appendValueInput('SUB')
            .appendField(Blockly.Msg.MIXLY_MICROPYTHON_SOCKET_MAKE)
            .setCheck("var");
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_SETUP + Blockly.Msg.LISTS_SET_INDEX_INPUT_TO)
            .appendField(new Blockly.FieldDropdown([
                ["MPU9250", "MPU9250"],
                ["BMP280", "BMP280"],
                ["SHT20", "SHT20"],
                ["ADXL345", "ADXL345"]
            ]), "key");
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setFieldValue("MPU9250", "key");
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var mode0 = Blockly.Msg.MIXLY_ESP32_SENSOR_USE_I2C_TOOLTIP;
            // var mode1 = Blockly.Msg.MIXLY_ESP32_NEAR;
            var TOOLTIPS = {
                "MPU9250": "MPU9250",
                "SHT20": "SHT20",
                "BMP280": "BMP280",
                "ADXL345": "ADXL345"
            };
            return mode0 + TOOLTIPS[mode]
        });
    }
};

//--结束---------------------------新增-20211227-------------------------------------------------
export const sensor_bmp = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("BMP280")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_GETTEMPERATUE, "get_BMP_temperature()"],
                [Blockly.Msg.MIXLY_GETPRESSURE, "get_BMP_pressure()"]
            ]), "key");
        this.setOutput(true, Number);
        this.setInputsInline(true);
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var TOOLTIPS = {
                "get_BMP_temperature()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_BMP_temperature_TOOLTIP,
                "get_BMP_pressure()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_BMP_press_TOOLTIP,
            };
            return TOOLTIPS[mode]
        });
    }
};

export const sensor_sht = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("SHT20")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown([
                [Blockly.Msg.MIXLY_GETTEMPERATUE, "get_SHT_temperature()"],
                [Blockly.Msg.MIXLY_GETHUMIDITY, "get_SHT_relative_humidity()"]
            ]), "key");
        this.setOutput(true, Number);
        this.setInputsInline(true);
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var TOOLTIPS = {
                "get_SHT_temperature()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_SHT_temperature_TOOLTIP,
                "get_SHT_relative_humidity()": Blockly.Msg.MIXLY_MICROBIT_SENSOR_SHT_HUM_TOOLTIP,
            };
            return TOOLTIPS[mode]
        });
    }
};

export const sensor_ds18x20 = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput("PIN", Number)
            .appendField("DS18x20 " + Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_GETTEMPERATUE);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_SENSOR_DS18X20_TOOLTIP);
    }
};

export const sensor_mpu9250_get_magnetic = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("MPU9250")
            .setCheck("var");
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_GET + Blockly.Msg.MIXLY_MICROBIT_JS_FIELD_STRENGTH)
            .appendField(new Blockly.FieldDropdown([
                ["x", "x"],
                ["y", "y"],
                ["z", "z"],
                ["(x,y,z)", "values"]
            ]), "key");
        this.setOutput(true, Number);
        this.setInputsInline(true);
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
            var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
            var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_FIELD_STRENGTH;
            var TOOLTIPS = {
                'x': 'x',
                'y': 'y',
                'z': 'z',
                '(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
            };
            return mode0 + TOOLTIPS[mode] + mode1 + mode2;
        });
    }
};

export const sensor_mpu9250_get_gyro = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("MPU9250")
            .setCheck("var");
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET + Blockly.Msg.MIXLY_ESP32_SENOR_GYRO)
            .appendField(new Blockly.FieldDropdown([
                ["x", "x"],
                ["y", "y"],
                ["z", "z"],
                ["(x,y,z)", "values"]
            ]), "key");
        this.setOutput(true, Number);
        this.setInputsInline(true);
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
            var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
            var mode2 = Blockly.Msg.MIXLY_ESP32_SENOR_GYRO;
            var TOOLTIPS = {
                'x': 'x',
                'y': 'y',
                'z': 'z',
                '(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
            };
            return mode0 + TOOLTIPS[mode] + mode1 + mode2;
        });
    }
};

export const sensor_lm35 = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_LM35);
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_GETTEMPERATUE);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_LM35);
    }
};


export const HCSR04 = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField(Blockly.Msg.MIXLY_CHAOSHENGBO);
        this.appendValueInput("PIN1", Number)
            .appendField('Trig #')
            .setCheck(Number);
        this.appendValueInput("PIN2", Number)
            .appendField('Echo #')
            .setCheck(Number);
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip(Blockly.Msg.MIXLY_TOOLTIP_BLOCKGROUP_CHAOSHENGBO);
    }

};

//-----------
export const sensor_dht11 = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("DHT11");
        this.appendValueInput("PIN", Number)
            .appendField(Blockly.Msg.MIXLY_PIN)
            .setCheck(Number);
        this.appendDummyInput("")
            .appendField("获取")
            .appendField(new Blockly.FieldDropdown([
                ["温度-℃", "0"],
                ["湿度-%", "1"],
                ["温湿度", "2"]
            ]), "TYPE")
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:传感器ADS1015，采集0-3通道模拟输入值-2047~+2047");
    }
};


export const sensor_mpu9250_temperature = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("MPU9250")
            .setCheck("var");
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_GETTEMPERATUE)
        this.setOutput(true, Number);
        this.setInputsInline(true);

        this.setTooltip(Blockly.Msg.MIXLY_GETTEMPERATUE);
    }
};

export const sensor_adxl345_get_acceleration = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("ADXL345")
            .setCheck("var");
        this.appendDummyInput()
            .appendField(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION)
            .appendField(new Blockly.FieldDropdown([
                ["x", "x"],
                ["y", "y"],
                ["z", "z"],
                ["(x,y,z)", "values"]
            ]), "key");
        this.setOutput(true, Number);
        this.setInputsInline(true);
        this.setTooltip(Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION);
        var thisBlock = this;
        this.setTooltip(function () {
            var mode = thisBlock.getFieldValue('key');
            var mode0 = Blockly.Msg.MIXLY_MICROBIT_PY_STORAGE_GET;
            var mode1 = Blockly.Msg.MIXLY_MICROBIT_Direction;
            var mode2 = Blockly.Msg.MIXLY_MICROBIT_JS_ACCELERATION1;
            var TOOLTIPS = {
                'x': 'x',
                'y': 'y',
                'z': 'z',
                '(x,y,z)': Blockly.Msg.MIXLY_MICROBIT_Shiliang_Direction,
            };
            return mode0 + TOOLTIPS[mode] + mode1 + mode2;
        });
    }
};


//--开始--------------------------新增-20211227-------------------------------------------------
export const sensor_asr_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("初始化")
            .setCheck("var");
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("语音识别");
        this.appendValueInput('SUBI2C')
            .setCheck("var")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("使用");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:使用I2C，初始化语音识别");
    }
};

export const sensor_asr_eraseWords = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput()
            .appendField("删除所有词条");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:语音识别，删除所有词条");
    }
};

export const sensor_asr_addWords = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput()
            .appendField("增加词条");
        this.appendValueInput('idNum')
            .appendField("编号")
            .setCheck(Number);
        this.appendValueInput('words')
            .appendField("拼音")
            .setCheck(String);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:语音识别，加词条要识别汉字词条的拼音，之间用空格隔开");
    }
};

export const sensor_asr_esetMode = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField("识别设置")
            .appendField(new Blockly.FieldDropdown([
                ["循环模式", "1"],
                ["口令模式", "2"],
                ["按键模式", "3"]
            ]), "TYPE")
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:语音识别，1：循环识模式。状态灯常亮（默认模式） 2：口令模式，以第一个词条为口令。状态灯常灭，当识别到口令词时常亮，等待识别到新的语音,并且读取识别结果后即灭掉  3：按键模式，按下开始识别，不按不识别。支持掉电保存。状态灯随按键按下而亮起，不按不亮");
    }
};

export const sensor_asr_getResult = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput()
            .appendField("启动识别 获取编号");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:语音识别，获取识别结果的编号");
    }
};



export const sensor_apds9960_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("初始化")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField("模式")
            .appendField(new Blockly.FieldDropdown([
                ["手势识别", "1"],
                ["颜色识别", "2"],
                ["接近测距", "3"]
            ]), "TYPE")
        this.appendValueInput('SUBI2C')
            .setCheck("var")
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("使用");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:使用I2C，初始化APDS9960模块");
    }
};

export const sensor_apds9960_readGesture = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField("获取")
            .appendField(new Blockly.FieldDropdown([
                ["识别手势", "1"],
                ["接近距离", "2"]
            ]), "TYPE")
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取手势识别结果，0:NONE,1:LEFT,2:RIGHT,3:UP,4:DOWN,5:NEAR,6:FAR,7:ALL");
    }
};

export const sensor_apds9960_readLRGB = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField("获取颜色")
            .appendField(new Blockly.FieldDropdown([
                ["红色值", "1"],
                ["绿色值", "2"],
                ["蓝色值", "3"],
                ["亮度值", "4"]
            ]), "TYPE")
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取识别颜色的LRGB");
    }
};


export const sensor_as608_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("初始化")
            .setCheck("var");
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("指纹识别");
        this.appendDummyInput()
            .appendField("通过")
            .appendField(new Blockly.FieldDropdown([['uart1', '1'], ['uart2', '2'], ['uart3', '3']]), 'mode');
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:使用串口，初始化AS608指纹识别模块");
    }
};

export const sensor_as608_savefig = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput()
            .appendField("录入指纹");
        this.appendValueInput('idNum')
            .appendField("编号")
            .setCheck(Number);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:录入指纹及对应的编号");
    }
};

export const sensor_as608_disfig = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("")
            .setCheck("var");
        this.appendDummyInput()
            .appendField("启动识别 获取编号");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:指纹识别，获取识别结果的编号");
    }
};

//--结束---------------------------新增-20211227-------------------------------------------------



//--开始--------------------------Amigo硬件 -20210920-------------------------------------------------

export const Amigo_KEY_SELET = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField(new Blockly.FieldDropdown([
                ["BACK", "23"],
                ["ENTER", "16"],
                ["NEXT", "20"]
            ]), "KEY");
        this.setOutput(true);
        this.setTooltip();
    }
};

//--开始-------------编码测速---20230309---------------------
export const sensor_encoder_init = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("初始化 电机编码")
            .setCheck("var");
        this.appendValueInput("PIN", Number)
            .appendField("管脚")
            .setCheck(Number);
        this.appendValueInput('scale')
            .appendField("每圈脉冲数")
            .setCheck(Number);
        this.appendValueInput('wheel')
            .appendField("轮子直径(cm)")
            .setCheck(Number);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:电机编码初始化，脉冲比即输出轴转动一圈所产生的脉冲数，和输入轮子直径(cm)");
    }
};

export const sensor_encoder_data = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendValueInput('SUB')
            .appendField("电机编码")
            .setCheck("var");
        this.appendDummyInput("")
            .appendField("获取")
            .appendField(new Blockly.FieldDropdown([
                ["圈数", "turns()"],
                ["路程", "distance()"],
                ["速度", "speed()"]
            ]), "TYPE")
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取电机的行驶路程和速度");
    }
};

//---------------TABIT板载传感器资源---20230520--------------------
export const sensor_tabit_charged = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 电池")
            .appendField(new Blockly.FieldDropdown([
                ["是否充电?", "ob_pmu.charged()"],
                ["是否充满?", "ob_pmu.fully_charged()"],
                ["电量电压V", "vbattery()"]
            ]), "TYPE")
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子电池状态");
    }
};

export const sensor_tabit_button = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 按键")
            .appendField(new Blockly.FieldDropdown([
                ["B1", "0"],
                ["B2", "1"],
                ["B3", "2"],
                ["B4", "3"],
                ["B5", "4"]
            ]), "TYPE");
        this.appendDummyInput()
            .appendField("被按着?");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子按键状态");
    }
};

export const sensor_tabit_acc = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 加速度(g)")
            .appendField(new Blockly.FieldDropdown([
                ["x", "acceleration()[0]"],
                ["y", "acceleration()[1]"],
                ["z", "acceleration()[2]"],
                ["(x,y,z)", "acceleration()"]
            ]), "TYPE");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子加速度状态");
    }
};

export const sensor_tabit_acc_euler = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 倾斜角(°)")
            .appendField(new Blockly.FieldDropdown([
                ["x", "eulerangles()[0]"],
                ["y", "eulerangles()[1]"],
                ["(x,y)", "eulerangles()"]
            ]), "TYPE");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子倾斜状态");
    }
};

export const sensor_tabit_als = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("获取 光线传感器(lux)")
            .appendField(new Blockly.FieldDropdown([
                ["日光", "als_vis()"],
                ["红外", "als_ir()"]
            ]), "TYPE");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子光线传感器数值");
    }
};

export const sensor_tabit_ps = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("获取 距离传感器");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子距离传感器数值");
    }
};

//---------------ASBIT板载传感器资源---20230722-------------------
export const sensor_asbit_button = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 按键")
            .appendField(new Blockly.FieldDropdown([
                ["A", "key_a"],
                ["B", "key_b"]
            ]), "TYPE");
        this.appendDummyInput()
            .appendField("被按着?");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子按键状态");
    }
};

//---------------LTBIT板载传感器资源---20230722-------------------
export const actuator_ltbit_set_HALL = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("设置编码");
        this.appendValueInput('scale')
            .appendField("每圈脉冲数")
            .setCheck(Number);
        this.appendValueInput('wheel')
            .appendField("轮子直径(cm)")
            .setCheck(Number);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:电机编码初始化，脉冲比即输出轴转动一圈所产生的脉冲数，和输入轮子直径(cm)");
    }
};

export const sensor_ltbit_hall_data = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("获取编码");
        this.appendDummyInput()
            .appendField("马达")
            .appendField(new Blockly.FieldDropdown([
                ['M1', '1'],
                ['M2', '2'],
                ['M3', '3'],
                ['M4', '4']
            ]), 'mode');
        this.appendDummyInput()
            .appendField("的")
            .appendField(new Blockly.FieldDropdown([
                ['圈数', '0'],
                ['距离(cm)', '1'],
                ['速度(cm/s)', '2']
            ]), 'data');
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取编码的信息");
    }
};

export const sensor_ltbit_hall_setdata = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("设置编码");
        this.appendDummyInput()
            .appendField("马达")
            .appendField(new Blockly.FieldDropdown([
                ['M1', '1'],
                ['M2', '2'],
                ['M3', '3'],
                ['M4', '4']
            ]), 'mode');
        this.appendDummyInput()
            .appendField("的")
            .appendField(new Blockly.FieldDropdown([
                ['圈数', '0'],
                ['距离(cm)', '1']
            ]), 'data');
        this.appendValueInput('value')
            .appendField("赋值为")
            .setCheck(Number);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:设置编码的信息");
    }
};

export const sensor_ltbit_hall_irq = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("编码中断");
        this.appendDummyInput()
            .appendField("马达")
            .appendField(new Blockly.FieldDropdown([
                ['M1', '1'],
                ['M2', '2'],
                ['M3', '3'],
                ['M4', '4']
            ]), 'mode');
        this.appendValueInput('DO')
            .appendField(Blockly.Msg.MIXLY_DO)
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("[Teaile]:设置编码的信息");
    }
};

export const sensor_ltbit_button = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 按键")
            .appendField(new Blockly.FieldDropdown([
                ["BOOT", "key_boot"]]), "TYPE");
        this.appendDummyInput()
            .appendField("被按着?");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子按键状态");
    }
};

//---------------AIBIT板载传感器资源---20240122-------------------
export const sensor_aibit_button = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 按键")
            .appendField(new Blockly.FieldDropdown([
                ["A", "key_a"],
                ["B", "key_b"],
                ["C", "key_c"]]), "TYPE");
        this.appendDummyInput()
            .appendField("被按着?");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子按键状态");
    }
};

export const sensor_aibit_button1 = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput("")
            .appendField("获取 按键")
            .appendField(new Blockly.FieldDropdown([
                ["A", "key_a"],
                ["B", "key_b"],
                ["C", "key_c"]]), "TYPE");
        this.appendDummyInput()
            .appendField("被按下?");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子按键状态");
    }
};

export const sensor_aibit_brightness = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("获取");
        this.appendDummyInput()
            .appendField("光线传感器的值");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("[Teaile]:获取板子光线传感器的值");
    }
};

//-------------RTC---------------------
export const sensor_rtc_set = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("RTC");
        this.appendValueInput('LIST')
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField("时间设置");
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setInputsInline(true);
        this.setTooltip("RTC时间设置, [年, 月, 日, 时, 分, 秒, 星期]");
    }
};

export const sensor_rtc_get = {
    init: function () {
        this.setColour(SENSOR_HUE);
        this.appendDummyInput()
            .appendField("RTC");
        this.appendDummyInput()
            .appendField("获取时间");
        this.appendDummyInput()
            .appendField("(年, 月, 日, 时, 分, 秒, 星期)");
        this.setInputsInline(true);
        this.setOutput(true, Number);
        this.setTooltip("RTC时间获取, 返回[年, 月, 日, 时, 分, 秒, 星期]");
    }
};